package com.ftg.midamall.admin.mapper;

import com.ftg.midamall.admin.dto.AdminInfo;
import org.apache.ibatis.annotations.*;

/**
 * @author qjw
 * @version 1.0
 * @date 2023/10/25 21:57
 */
@Mapper
public interface UmsAdminRoleMapper {

    @Delete("delete from ums_admin_role_relation where role_id=#{role_id}")
    int delRole(@Param("role_id") Long role_id);

    @Insert("insert into ums_admin_role_relation(admin_id,role_id) values(#{admin_id},#{role_id})")
    int saveRole(@Param("admin_id") Long admin_id, @Param("role_id") Long role_id);

    @Select("select id from ums_admin where username=#{username}")
    Long findAdminIdByUsername(@Param("username") String username);

    AdminInfo selectByNameId(@Param("username") String username, @Param("id") Long id);

    @Delete("delete from ums_admin_role_relation where admin_id=#{admin_id}")
    int delAdmin(@Param("admin_id") Long admin_id);
    /**
     * 为用户分配角色
     * @param admin_id
     * @param role_id
     * @return
     */
    int insertAdminRoleRelation(@Param("admin_id") Long admin_id, @Param("role_id") Long role_id);


}
